package com.hxgz.steel.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxgz.steel.common.ServerResponse;
import com.hxgz.steel.dao.IntegralMapper;
import com.hxgz.steel.domain.Integral;
import com.hxgz.steel.domain.Page;
import com.hxgz.steel.domain.User;
import com.hxgz.steel.service.IntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class IntegralServiceImpl implements IntegralService {

    @Autowired
    private IntegralMapper integralMapper;

    @Override
    public ServerResponse getIntegralList(Long userId, Page page,Integer type){
        PageHelper.startPage(page.getCurrPageNo(),page.getPageSize());
        List<Integral> integralList = integralMapper.getIntegralList(userId,type);
        PageInfo pageInfo = new PageInfo(integralList);
        return ServerResponse.createBySuccess(pageInfo);

    }

    @Override
    public ServerResponse cleanIntegral(Long userId){
        if(integralMapper.cleanIntegral(userId)>0){
            return ServerResponse.createBySuccessMessage("清除成功！");
        }

        return ServerResponse.createByErrorMessage("清除失败");
    }

}
